package com.nbsaas.boot.app.rest.convert;

import com.nbsaas.boot.app.data.entity.AppMenu;
import com.nbsaas.boot.app.api.domain.response.AppMenuResponse;

import com.nbsaas.boot.utils.BeanDataUtils;
import com.nbsaas.boot.rest.api.Converter;
/**
* 实体对象转化成响应对象
*/

public class AppMenuResponseConvert  implements Converter<AppMenuResponse,AppMenu> {

    @Override
    public AppMenuResponse convert(AppMenu source) {
        AppMenuResponse  result = new  AppMenuResponse();
        BeanDataUtils.copyProperties(source, result);
                    if(source.getApp()!=null){
                        result.setApp(source.getApp().getId());
                    }
                    if(source.getParent()!=null){
                        result.setParent(source.getParent().getId());
                    }
                    if(source.getApp()!=null){
                        result.setAppName(source.getApp().getName());
                    }
                    if(source.getParent()!=null){
                        result.setParentName(source.getParent().getName());
                    }
        return result;
    }

}

